﻿namespace A2DFramework.OSGI.BundleContexts
{
    using System;

    public class SandBoxModuleContext : BundleContext
    {
        private static SandBoxModuleContext instance;

        private SandBoxModuleContext(string moduleName)
        {
            base.Name = moduleName;
        }

        public static SandBoxModuleContext Current
        {
            get
            {
                if (AppDomain.CurrentDomain.IsDefaultAppDomain())
                {
                    throw new Exception("SandBoxModuleContext cannot be used in default domain");
                }
                if (instance == null)
                {
                    instance = new SandBoxModuleContext(AppDomain.CurrentDomain.FriendlyName);
                }
                return instance;
            }
        }
    }
}

